package com.admin.mapper;

import com.admin.entity.Station;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author marisheng
 * @since 2019-11-21
 */
public interface StationMapper extends BaseMapper<Station> {

    //根据站点编号查询站点详表
    public Map findByIdStation(@Param("m") Map m);

    public Map<Station, String> findByBhStation(@Param("m") Map m);

    /**
     * 计费分页查询
     *
     * @param page
     * @param map
     * @return
     */
    public IPage querywocoin(Page page, @Param("m") Map map);

    /**
     * 查询所有的站点可以根据编号/时间/上级
     * @param page
     * @param map
     * @return
     */
    public IPage selectAllStation(Page page, @Param("m") Map map);

    //密钥分页
    public IPage selectPasswodFenye(Page page,@Param("m") Map map);
    /**
     * 查询统计
     *
     * @param map 查询参数
     * @return
     */
    public int querCount(@Param("m") Map map);

    /**
     * 分页查询可以删除的站点
     * @param page
     * @param map
     * @return
     */
    public IPage selectAllDelStation(Page page, @Param("m") Map map);

    /**
     * 查询当前用户下的所有站点信息包括他的下级的下级
     * @param ids 所有用户id字符串
     * @return 站点id，站点当前绑定终端数
     */
    @Select("select station_id,staion_current_number_o_terminals from station where station_admin_id in (${ids})")
    List<Station> getSuoyouzhandianbyid(String ids);

    /**
     * 查询是否是管理员
     * @param station_id
     * @return
     */
    public Map queryThemeAdmin(@Param("station_id") Integer station_id);

    @Select("select * from station where station_phone=#{username} and station_password=#{password}")
    Station queryStationLoginMapper(@Param("username") String username, @Param("password") String password);

    /**
     * 查所有版权授权的站点
     * @param page
     * @param search
     * @return
     */
    public IPage selCopyRightStation(Page page ,@Param("search")String search,@Param("copyrightid") int copyrightid,@Param("token") List token);

    @Select(" select station_admin_id from station where station_bh=#{stationbh}")
    public int selectIdByStationBh(String stationbh);
}
